package cn.swust.designpatternlearningplatform.common;




import cn.swust.designpatternlearningplatform.common.exception.ParamNullException;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.stereotype.Component;

@Aspect
@Component
@Slf4j
public class NotNullAOP {
    @Before("@annotation(cn.swust.designpatternlearningplatform.common.AnnotationUtils.NotNull)")
    public void checkParam(JoinPoint joinPoint) {
        Object[] o = joinPoint.getArgs();
        for (Object o1 : o) {
            if(o1 == null || o1.toString().equals("")) {
                throw new ParamNullException();
            }
        }
    }
}
